<template>
  <tr>
    <td></td>
    <td>
      商品名:<input type="text" v-model="name">
    </td>
    <td>
      价格:<input type="text" v-model.number="price">
    </td>
    <td>
      <button @click="add">添加</button>
    </td>
  </tr>
</template>

<script>
export default {
  props:['arr'],
  data () {
    return {
      name:'',
      price:''
    }
  },
  methods: {
    add(){
      if(this.name==='') return alert('商品名不能为空')
      if(this.price==='') return alert('价格不能为空')
      this.arr.push({name:this.name,price:this.price,num:1,checked:false})
      this.name=''
      this.price=''
    }
  }
}
</script>

<style scoped>

</style>
